# -*- coding: utf-8 -*-

# Scrapy settings for lagou project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://doc.scrapy.org/en/latest/topics/settings.html
#     https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://doc.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'lagou'

SPIDER_MODULES = ['lagou.spiders']
NEWSPIDER_MODULE = 'lagou.spiders'



# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'lagou (+http://www.yourdomain.com)'

# Obey robots.txt rules
ROBOTSTXT_OBEY = False
DOWNLOAD_DELAY = 2
# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
#DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
#CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
#DEFAULT_REQUEST_HEADERS = {
#   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
#   'Accept-Language': 'en',
#}

# Enable or disable spider middlewares
# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
#    'lagou.middlewares.LagouSpiderMiddleware': 543,
#}

# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
# DOWNLOADER_MIDDLEWARES = {
#    # 'lagou.middlewares.LagouDownloaderMiddleware': 543,
#     'lagou.user_agent_middlewares.RandomUserAgentMiddlware': 543,
#     'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware':None,
# }
DOWNLOADER_MIDDLEWARES = {
    #    'myproxies.middlewares.MyCustomDownloaderMiddleware': 543,
    'lagou.user_agent_middlewares.RandomUserAgentMiddlware': 700,
    'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
    'scrapy.contrib.downloadermiddleware.httpproxy.HttpProxyMiddleware': None,
    'lagou.user_agent_middlewares.ProxyMiddleWare': 650,
    'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware': None
}


# Enable or disable extensions
# See https://doc.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
#}

# Configure item pipelines
# See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
   'lagou.pipelines.LagouPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
HEADERS = {
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    #'Cookie': '_ga=GA1.2.843009331.1522143717; user_trace_token=20180327174158-18250b07-31a3-11e8-b64b-5254005c3644; LGUID=20180327174158-18251096-31a3-11e8-b64b-5254005c3644; index_location_city=%E6%B7%B1%E5%9C%B3; WEBTJ-ID=20180420105641-162e0fb801a9-03260a2a52f61c-3e3d5f01-1440000-162e0fb801c159; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1522236861,1523868920,1523955273,1524193002; _gid=GA1.2.418725946.1524193002; JSESSIONID=ABAAABAAAFCAAEGCF5111EDC999DA1E0F13B661D440FB8E; TG-TRACK-CODE=search_code; X_HTTP_TOKEN=f8d8a15a08b06164afcf472f09183ffa; LGSID=20180420141612-530e8256-4462-11e8-b8bf-5254005c3644; PRE_UTM=; PRE_HOST=; PRE_SITE=; PRE_LAND=https%3A%2F%2Fpassport.lagou.com%2Flogin%2Flogin.html%3Fts%3D1524204971509%26serviceId%3Dlagou%26service%3Dhttps%25253A%25252F%25252Fwww.lagou.com%25252Fc%25252Fapprove.json%25253FcompanyIds%25253D119788%2525252C26399%2525252C128998%2525252C267%2525252C135243%2525252C5580%2525252C48687%2525252C7918%2525252C112144%2525252C79761%2525252C385%2525252C52004%2525252C28834%2525252C4558%2525252C16831%26action%3Dlogin%26signature%3D675394CC81B577C384B7623D9D76DE56; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1524205952; LGRID=20180420143232-9b6536a5-4464-11e8-b8c0-5254005c3644; SEARCH_ID=481e66da07ac4f8f8b745bc85c4ca57d',
    'Host': 'www.lagou.com',
    'Origin': 'https://www.lagou.com',
    'Referer': 'https://www.lagou.com/jobs/list_%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0?city=%E5%85%A8%E5%9B%BD&cl=false&fromSearch=true&labelWords=&suginput=',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36',
}
HEADERS1 = {
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Host': 'www.lagou.com',
    'Origin': 'https://www.lagou.com',
    'X-Anit-Forge-Code': '0',
    'X-Anit-Forge-Token': 'None',
    'X-Requested-With': 'XMLHttpRequest',
}
RANDOM_UA_TYPE = 'random'##random    chrome
#RANDOM_UA_TYPE = 'chrome'
KEYWORD = '数据分析'

MONGO_URI = 'localhost'
MONGO_DATABASE = 'lagoudb'
MONGO_TABLE = 'lagou'